gdm/authPrompt: Preserve the text when switching entry visibility
The text visibility of an auth prompt entry may change dynamically at
runtime, in particular when unlocking the screen with the blank screen
or with the screen shield visible this is happening:
- The user starts typing the PAM credential (may be secret or not)
- Under the hood the PAM conversation starts and actually asks user
for input
- The entry text is not cleared because we use what the user has typed
so far as the preemptive secret.
- The entry is adjusted to follow the requested PAM text visibility
settings.
-> This may lead to switching the actual text entry widget in use
Now, if the first entry that PAM requires is "ECHO ON", like it may
happen in the case in which a visible value is requested, we end up
"clearing" what the user as typed instead of preserving the value as
pre-filled value.
Causing the user typing something wrong instead.
To prevent this we need to restore both the text, the cursor position
and the selection bounds (in case the use pressed some key [binding])
leading to a position or selection change.